fix(synchronizeBlocksWithTemplate): Fix, merge template attributes on update #12406
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As per #11873 - we were having the same issue whilst making a custom Section block (cc #4900). This fix will resolve that problem.
The issue we had was that block attributes weren't updating despite the template changing, if the block that was updating was already in the correct position. (Primarily in the case of columns for us - but true of any template)
This PR moves the block return below the NormalizeAttribute function so we can access the normalized attributes. It then returns the updated attributes as part of the block, ensuring that if the template attributes change, they are correctly reflected.
How has this been tested?
Tested against the columns to ensure that they continue to work without any additional template changes.
Built the plugin and run in our development and staging environments to allow us to use custom templates that require this functionality.
Types of changes
Bug fix - attributes previously not updated as part of block synchronise.
Checklist: